package com.hqd.ch03.v50.factory;

import com.hqd.ch03.v50.beans.PropertyEditorRegistrar;
import com.hqd.ch03.v50.beans.TypeConverter;
import com.hqd.ch03.v50.beans.converter.ConversionService;
import com.hqd.ch03.v50.beans.factory.BeanDefinitionStoreException;
import com.hqd.ch03.v50.beans.factory.NoSuchBeanDefinitionException;
import com.hqd.ch03.v50.beans.factory.config.BeanDefinition;
import com.hqd.ch03.v50.beans.property.PropertyEditorRegistry;
import com.hqd.ch03.v50.config.BeanPostProcessor;
import com.hqd.ch03.v50.config.Scope;
import com.hqd.ch03.v50.config.StringValueResolver;
import com.hqd.ch03.v50.core.metrics.ApplicationStartup;
import com.hqd.ch03.v50.registry.SingletonBeanRegistry;
import com.hqd.ch03.v50.spel.BeanExpressionResolver;

import java.beans.PropertyEditor;
import java.security.AccessControlContext;

/**
 * 可配置的Bean工厂
 */
public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, SingletonBeanRegistry {
    //单例
    String SCOPE_SINGLETON = "singleton";
    //多例
    String SCOPE_PROTOTYPE = "prototype";

    /**
     * 设置父容器
     *
     * @param parentBeanFactory
     * @throws IllegalStateException
     */
    void setParentBeanFactory(BeanFactory parentBeanFactory) throws IllegalStateException;

    ClassLoader getBeanClassLoader();

    /**
     * 设置Bean加载器
     *
     * @param beanClassLoader
     */
    void setBeanClassLoader(ClassLoader beanClassLoader);

    void registerScope(String scopeName, Scope scope);

    ClassLoader getTempClassLoader();

    void setTempClassLoader(ClassLoader tempClassLoader);

    boolean isCacheBeanMetadata();

    void setCacheBeanMetadata(boolean cacheBeanMetadata);

    BeanExpressionResolver getBeanExpressionResolver();

    void setBeanExpressionResolver(BeanExpressionResolver resolver);


    ConversionService getConversionService();

    void setConversionService(ConversionService conversionService);

    void addPropertyEditorRegistrar(PropertyEditorRegistrar registrar);

    void registerCustomEditor(Class<?> requiredType, Class<? extends PropertyEditor> propertyEditorClass);

    void copyRegisteredEditorsTo(PropertyEditorRegistry registry);

    TypeConverter getTypeConverter();

    void setTypeConverter(TypeConverter typeConverter);

    void addEmbeddedValueResolver(StringValueResolver valueResolver);

    boolean hasEmbeddedValueResolver();

    String resolveEmbeddedValue(String value);

    void addBeanPostProcessor(BeanPostProcessor beanPostProcessor);

    int getBeanPostProcessorCount();


    String[] getRegisteredScopeNames();

    Scope getRegisteredScope(String scopeName);

    ApplicationStartup getApplicationStartup();

    void setApplicationStartup(ApplicationStartup applicationStartup);

    AccessControlContext getAccessControlContext();

    void copyConfigurationFrom(ConfigurableBeanFactory otherFactory);

    void registerAlias(String beanName, String alias) throws BeanDefinitionStoreException;

    void resolveAliases(StringValueResolver valueResolver);

    BeanDefinition getMergedBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;

    boolean isFactoryBean(String name) throws NoSuchBeanDefinitionException;

    void setCurrentlyInCreation(String beanName, boolean inCreation);

    boolean isCurrentlyInCreation(String beanName);

    void registerDependentBean(String beanName, String dependentBeanName);

    String[] getDependentBeans(String beanName);

    String[] getDependenciesForBean(String beanName);

    void destroyBean(String beanName, Object beanInstance);

    void destroyScopedBean(String beanName);

    void destroySingletons();

}

